﻿using BLL;
using DAL;
using Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UI
{
    public partial class UserIoginForm : Form
    {
        public UserIoginForm()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //获取用户交互的数据
            string uname = textBox1.Text;
            string pwd = textBox2.Text;
            UserInfo userInfo = new UserInfo();
            userInfo.Username = uname;
            userInfo.Password = pwd;

            //调用BLL层，完成业务处理
            UserInfoBLL userInfoBLL = new UserInfoBLL();

            switch (userInfoBLL.UserInfoLogin(userInfo))
            {
                case 0:
                    label4.ForeColor = Color.Green;
                    label4.Text = "登录成功";
                    //弹出员工管理系统
                    this.Hide();
                    UserInfoForm userInfoForm = new UserInfoForm(this);
                    userInfoForm.Show();
                    break;
                case -1:
                    label4.ForeColor = Color.Red;
                    label4.Text = "用户名或密码有误";
                    break;
                case 1:
                    label4.ForeColor = Color.Red;
                    label4.Text = "非经理用户无法登录";
                    break;

            }
        }




    }
}
